package us.wili.dev.client.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import us.wili.dev.client.dao.ClientRotaMapper;
import us.wili.dev.client.model.rsp.GoodsRsp;
import us.wili.dev.client.service.ClientGoodsService;
import us.wili.dev.client.service.ClientRotaService;
import us.wili.dev.model.entity.Goods;
import us.wili.dev.model.entity.Rota;
import us.wili.dev.model.example.RotaExample;
import us.wili.dev.service.impl.BaseRotaServiceImpl;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ClientRotaServiceImpl extends BaseRotaServiceImpl implements ClientRotaService {
    @Resource
    private ClientRotaMapper clientRotaMapper;

    @Autowired
    private ClientGoodsService clientGoodsService;

    @Override
    public List<Rota> rotas() {
        List<Rota> list = searRotas();
        return list;
    }

    @Override
    public GoodsRsp rotajump(Long id) {
        Rota rota = searrota(id);
        Goods goods = clientGoodsService.rotaGood(rota);
        GoodsRsp rsp = clientGoodsService.goodsdeta(goods.getId());
        return rsp;
    }

    public List<Rota> searRotas(){
        RotaExample example = new RotaExample();
        example.createCriteria();
        return clientRotaMapper.selectByExample(example);
    }

    public Rota searrota(Long id){
        RotaExample example = new RotaExample();
        example.createCriteria().andIdEqualTo(id);
        return clientRotaMapper.selectOneByExample(example);
    }
}
